package com.itdaan.portal.common.util;

import org.springframework.context.ApplicationContext;

/**
 * 获取上下文工具类
 * @author www.itdaan.com
 */
public class BeanLocator {
	private static BeanLocator instance = null;
	private ApplicationContext applicationContext = null;

	private BeanLocator() {
	}

	public static BeanLocator getInstance() {
		if (instance == null) {
			synchronized (BeanLocator.class) {
				if (instance == null) {
					instance = new BeanLocator();
				}
			}
		}
		return instance;
	}

	public ApplicationContext getApplicationContext() {
		return applicationContext;
	}

	public void setApplicationContext(ApplicationContext applicationContext) {
		this.applicationContext = applicationContext;
	}

	public Object getBean(String beanName) {
		return applicationContext.getBean(beanName);
	}
}
